package com.day1014;

import com.cilent.User;

import java.io.InputStream;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class MainText {
    public static void main(String[] args) throws Exception{
        ServerSocket serverSocket = new ServerSocket(8888);
        Socket socket = serverSocket.accept();
        InputStream inputStream = socket.getInputStream();
        ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
        Object obj = objectInputStream.readObject();
        User user = (User) obj;
        System.out.println(user.getName());
        System.out.println(user.getPwd());
        if (user.getName().equals("admin")){
            if (user.getPwd().equals("123")){
                String s = "登录成功";
                System.out.println(s);
            }
            else {
                String s = "登录失败";
                System.out.println(s);
            }
        }
        objectInputStream.close();
        inputStream.close();
        socket.close();
        serverSocket.close();

    }
}
